home *** CD-ROM | disk | FTP | other *** search
-
- dim light ' Lighting ON/OFF
- dim blend ' Blending OFF/ON? ( NEW )
-
- dim xrot# ' X Rotation
- dim yrot# ' Y Rotation
- dim xspeed# ' X Rotation Speed
- dim yspeed# ' Y Rotation Speed
- dim z#: z#=-5 ' Depth Into The Screen
-
- dim LightAmbient#(3): LightAmbient# = vec4 ( 0.5, 0.5, 0.5, 1.0 )
- dim LightDiffuse#(3): LightDiffuse# = vec4 ( 1.0, 1.0, 1.0, 1.0 )
- dim LightPosition#(3): LightPosition# = vec4 ( 0.0, 0.0, 2.0, 1.0 )
-
- dim filter ' Which Filter To Use
- dim texture(2) ' Storage For 3 Textures
- dim key$
-
- dim image
- image = LoadImage ("Data/Glass.png")
- glGenTextures (3, texture)
-
- glBindTexture (GL_TEXTURE_2D, texture (0))
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
- glTexImage2D (GL_TEXTURE_2D, 0, 3, ImageWidth(image), ImageHeight(image), 0, ImageFormat(image), ImageDataType(image), image)
-
- glBindTexture (GL_TEXTURE_2D, texture (1))
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
- glTexImage2D (GL_TEXTURE_2D, 0, 3, ImageWidth(image), ImageHeight(image), 0, ImageFormat(image), ImageDataType(image), image)
-
- glBindTexture (GL_TEXTURE_2D, texture (2))
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST)
- gluBuild2DMipmaps (GL_TEXTURE_2D, 3, ImageWidth(image), ImageHeight(image), ImageFormat(image), ImageDataType(image), image)
-
- DeleteImage (image)
-
- ' Setup OpenGL
-
- glEnable(GL_TEXTURE_2D)
- glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient#) ' Setup The Ambient Light
- glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse#) ' Setup The Diffuse Light
- glLightfv(GL_LIGHT1, GL_POSITION,LightPosition#) ' Position The Light
- glEnable(GL_LIGHT1) ' Enable Light One
-
- glColor4f(1.0, 1.0, 1.0, 0.5) ' Full Brightness. 50% Alpha
- glBlendFunc(GL_SRC_ALPHA,GL_ONE) ' Set The Blending Function For Translucency
-
- ' Main loop
-
- while true
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) ' Clear The Screen And The Depth Buffer
- glLoadIdentity() ' Reset The View
- glTranslatef(0.0,0.0,z#)
-
- glRotatef(xrot#,1.0,0.0,0.0)
- glRotatef(yrot#,0.0,1.0,0.0)
-
- glBindTexture(GL_TEXTURE_2D, texture(filter))
-
- glBegin(GL_QUADS)
- ' Front Face
- glNormal3f( 0.0, 0.0, 1.0)
- glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
- glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
- glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, 1.0)
- glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, 1.0)
- ' Back Face
- glNormal3f( 0.0, 0.0,-1.0)
- glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, -1.0)
- glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
- glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
- glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, -1.0)
- ' Top Face
- glNormal3f( 0.0, 1.0, 0.0)
- glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
- glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, 1.0, 1.0)
- glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, 1.0, 1.0)
- glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
- ' Bottom Face
- glNormal3f( 0.0,-1.0, 0.0)
- glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, -1.0, -1.0)
- glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, -1.0, -1.0)
- glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
- glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
- ' Right face
- glNormal3f( 1.0, 0.0, 0.0)
- glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, -1.0)
- glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
- glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, 1.0)
- glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
- ' Left Face
- glNormal3f(-1.0, 0.0, 0.0)
- glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, -1.0)
- glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
- glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, 1.0)
- glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
- glEnd()
-
- xrot# = xrot# + xspeed#
- yrot# = yrot# + yspeed#
-
- SwapBuffers ()
-
- key$ = Inkey$ ()
- if key$ = "L" or key$ = "l" then
- light = not light
- if not light then
- glDisable (GL_LIGHTING)
- else
- glEnable (GL_LIGHTING)
- endif
- endif
- if key$ = "F" or key$ = "f" then
- filter = filter + 1
- if filter > 2 then
- filter = 0
- endif
- endif
- if ScanKeyDown (VK_PRIOR) then
- z# = z# - 0.02
- endif
- if ScanKeyDown (VK_NEXT) then
- z# = z# + 0.02
- endif
- if ScanKeyDown (VK_UP) then
- xspeed# = xspeed# - 0.01
- endif
- if ScanKeyDown (VK_DOWN) then
- xspeed# = xspeed# + 0.01
- endif
- if ScanKeyDown (VK_RIGHT) then
- yspeed# = yspeed# + 0.01
- endif
- if ScanKeyDown (VK_LEFT) then
- yspeed# = yspeed# - 0.01
- endif
- if key$ = "B" or key$ = "b" then
- blend = not blend
- if blend then
- glEnable (GL_BLEND)
- glDisable (GL_DEPTH_TEST)
- else
- glDisable (GL_BLEND)
- glEnable (GL_DEPTH_TEST)
- endif
- endif
- wend